﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MockPrjTeam2.Entity;
using MockPrjTeam2.Biz;

namespace MockPrjTeam2.Pages.Controls
{
    public partial class UCSearchAddress : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ShowAllAddress();
        }
        private void ShowAllAddress()
        {
            var listAddr = new List<Address>();
            var getAddr = new AddressBiz();
            listAddr = getAddr.getAllAddress();

            GVSearchAddress.DataSource = listAddr;
            GVSearchAddress.DataBind();
        } 
        protected void btSearch_Click(object sender, EventArgs e)
        {
            var listAddr = new List<Address>();
            var getAddr = new AddressBiz();
            listAddr = getAddr.getAddressesByKey(Convert.ToString(txtPostCode.Text), Convert.ToString(txtStreet.Text), Convert.ToString(txtTown.Text));

            if (listAddr != null)
            {
                GVSearchAddress.DataSource = listAddr;
                GVSearchAddress.DataBind();
            }
        }

        protected void btNone_Click(object sender, EventArgs e)
        {
            ShowAllAddress();
        }

        protected void btSelect_Click(object sender, EventArgs e)
        {
            string selectedValue = Request.Form["MyRadioButton"];
            lblMsg.Text = selectedValue;
        }       
    }
}